package com.dlwx.parttimetalent.base;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;


/**
 * @作者 wch
 * @create at 2017/1/12 0012 下午 4:24
 * @name 父类fragment
 */
public abstract class BaseFragment extends Fragment implements View.OnClickListener {
    public Context ctx;
    private Display display;
    private int height;
//    public MyProgressLoading loading;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        ctx = getActivity();
        View view = inflater.inflate(getLayoutID(), null);
        display = getActivity().getWindowManager().getDefaultDisplay();
        height = display.getHeight();
//        loading = new MyProgressLoading(ctx, R.style.DialogStyle);
        initView(view);
        initDate();
        initListener();

        return view;
    }

    /**
     * 获得布局id
     *
     * @return
     */
    public abstract int getLayoutID();

    /**
     * 初始化控件
     */
    protected abstract void initView(View view);

    /**
     * 初始化数据
     */
    protected abstract void initDate();

    /**
     * 时间监听
     */
    protected abstract void initListener();

    @Override
    public void onClick(View v) {

    }

    /**
     * 弹吐司
     *
     * @param message
     */
    public void toast(Object message) {
        Toast toast = Toast.makeText(ctx, message + "", Toast.LENGTH_LONG);
//        toast.setGravity(Gravity.TOP, 0, height / 13);
        toast.show();
    }

    /**
     * 日志信息
     *
     * @param message
     */
    public void wch(Object message) {
        Log.i("wch", message + "");
    }

    /**
     * 显示加载框
     *
     * @param view
     */
//    public void showPopuPress(View view) {
//        new LoadPressUtiles(ctx, view);
//    }


}
